//
//  NSChatPrivateGuideView.m
//  Meboo
//
//  Created by kyo on 2024/6/1.
//

#import "NSChatPrivateGuideView.h"
#import "NSVipViewController.h"
#import "NSVipPopView.h"
@interface NSChatPrivateGuideView ()
//背景图
@property (nonatomic, strong) UIImageView *backImageView;
//顶部图标
@property (nonatomic, strong) UIImageView *iconImageView;
//下面6段文字
@property (nonatomic, strong) UILabel *label1;
@property (nonatomic, strong) UILabel *label2;
@property (nonatomic, strong) UILabel *label3;
@property (nonatomic, strong) UILabel *label4;
@property (nonatomic, strong) UILabel *label5;
@property (nonatomic, strong) UILabel *label6;
//Own a private album
@property (nonatomic, strong) UIButton *nextBtn;
//pop
@property (nonatomic , strong) NSVipPopView *vipPopView;
@end

@implementation NSChatPrivateGuideView

#pragma mark - Life Cycle
- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self setupUI];
    }
    return self;
}

#pragma mark - Action
- (void)nextAction {
    if ([MBUserAccount defaultAccount].isVip) {
        self.hidden = YES;
        if (self.nullBlock) {
            self.nullBlock();
        }
    } else {
        [kKeyWindow addSubview:self.vipPopView];
        self.vipPopView.index = 5;
        self.vipPopView.hidden = NO;
    }
}

- (void)leftAction {
    [self.currentViewController.navigationController popViewControllerAnimated:YES];
}

#pragma mark - UI
- (void)setupUI {
    
    self.backgroundColor = UIColor.whiteColor;
    [self addSubview:self.backImageView];
    [self.backImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self);
    }];
    
    
    [self addSubview:self.iconImageView];
    [self.iconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self);
        make.top.mas_equalTo(MBHeightScale(60));
        make.width.mas_equalTo(MBWidthScale(162));
        make.height.mas_equalTo(MBWidthScale(162)/162*147);
    }];
    
    [self addSubview:self.label1];
    [self.label1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.iconImageView.mas_bottom).offset(MBHeightScale(35));
        make.centerX.equalTo(self);
    }];
    
    [self addSubview:self.label2];
    [self.label2 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.label1.mas_bottom).offset(MBHeightScale(35));
        make.centerX.equalTo(self);
    }];
    
    [self addSubview:self.label3];
    [self.label3 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.label2.mas_bottom).offset(MBHeightScale(7));
        make.centerX.equalTo(self);
        make.left.mas_equalTo(MBWidthScale(20));
    }];
    
    [self addSubview:self.label4];
    [self.label4 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.label3.mas_bottom).offset(MBHeightScale(26));
        make.centerX.equalTo(self);
    }];
    
    [self addSubview:self.label5];
    [self.label5 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.label4.mas_bottom).offset(MBHeightScale(7));
        make.centerX.equalTo(self);
        make.left.mas_equalTo(MBWidthScale(20));
    }];
    
    [self addSubview:self.nextBtn];
    [self.nextBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(MBHeightScale(52));
        make.centerX.equalTo(self);
        make.left.mas_equalTo(MBWidthScale(12));
        make.bottom.mas_equalTo(-MBHeightScale(15)-TabbarSafeBottomMargin);
    }];
    
    [self addSubview:self.label6];
    [self.label6 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(self.nextBtn.mas_top).offset(MBHeightScale(-15));
        make.centerX.equalTo(self);
    }];
    
    //pop
    [self vipPopView];
}

#pragma mark - Setter && Getter
- (UIImageView *)iconImageView {
    if (!_iconImageView) {
        _iconImageView = [UIImageView new];
        _iconImageView.image = ImageWithName(@"chat_private_guide");
    }
    return _iconImageView;
}

- (UILabel *)label1 {
    if (!_label1) {
        _label1 = [UILabel new];
        _label1.textAlignment = NSTextAlignmentCenter;
        _label1.font = PDBoldScale(20);
        _label1.textColor = HEXS(@"000000");
        _label1.numberOfLines = 0;
        _label1.text = @"How Can Private Albums\nProtect Your Privacy?";
    }
    return _label1;
}

- (UILabel *)label2 {
    if (!_label2) {
        _label2 = [UILabel new];
        _label2.textAlignment = NSTextAlignmentCenter;
        _label2.font = PDBoldScale(16);
        _label2.textColor = HEXS(@"000000");
        _label2.numberOfLines = 0;
        _label2.text = @"Nobody will Find it";
    }
    return _label2;
}

- (UILabel *)label3 {
    if (!_label3) {
        _label3 = [UILabel new];
        _label3.textAlignment = NSTextAlignmentCenter;
        _label3.font = PDRegularScale(14);
        _label3.textColor = HEXS(@"000000");
        _label3.numberOfLines = 0;
        _label3.text = @"Save your most cheekiest photos here and never to worry about that anyone will find it.";
    }
    return _label3;
}

- (UILabel *)label4 {
    if (!_label4) {
        _label4 = [UILabel new];
        _label4.textAlignment = NSTextAlignmentCenter;
        _label4.font = PDBoldScale(16);
        _label4.textColor = HEXS(@"000000");
        _label4.numberOfLines = 0;
        _label4.text = @"Nobody can Share it";
    }
    return _label4;
}

- (UILabel *)label5 {
    if (!_label5) {
        _label5 = [UILabel new];
        _label5.textAlignment = NSTextAlignmentCenter;
        _label5.font = PDRegularScale(14);
        _label5.textColor = HEXS(@"000000");
        _label5.numberOfLines = 0;
        _label5.text = @"Private photos can't be saved, screenshotted, or forwarded by others. Once sent, they will self-destruct 1 hour after being opened.";
    }
    return _label5;
}

- (UILabel *)label6 {
    if (!_label6) {
        _label6 = [UILabel new];
        _label6.textAlignment = NSTextAlignmentCenter;
        _label6.font = PDRegularScale(16);
        _label6.textColor = HEXS(@"000000");
        _label6.numberOfLines = 0;
        _label6.text = @"Get yourself premium to";
    }
    return _label6;
}

- (UIButton *)nextBtn {
    if (!_nextBtn) {
        _nextBtn = [UIButton new];
        [_nextBtn setTitle:@"Own a private album" forState:0];
        [_nextBtn setBackgroundColor:HEXS(@"B92176")];
        [_nextBtn setTitleColor:UIColor.whiteColor forState:0];
        _nextBtn.layer.cornerRadius = MBHeightScale(52/2);
        _nextBtn.titleLabel.font = PDSemiBoldScale(16);
        [_nextBtn addTarget:self action:@selector(nextAction) forControlEvents:UIControlEventTouchUpInside];
    }
    return _nextBtn;
}

- (UIImageView *)backImageView {
    if (!_backImageView) {
        _backImageView = [UIImageView new];
        _backImageView.image = ImageWithName(@"home_back_image");
    }
    return _backImageView;
}

- (NSVipPopView *)vipPopView {
    if (!_vipPopView) {
        _vipPopView = [[NSVipPopView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight)];
    }
        return _vipPopView;
}
@end
